<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="telephone=no" name="format-detection" />
    <title>注册</title>
    <link href="{{ static('css/main.css') }}" rel="stylesheet" type="text/css">
    <link href="{{ static('css/style.css') }}" rel="stylesheet" type="text/css">
    <link href="{{ static('css/shake.css') }}" rel="stylesheet" type="text/css">
    <link href="{{ static('css/font-awesome.min.css') }}" rel="stylesheet" type="text/css">
    <link href="{{ static('css/animate.min.css') }}" rel="stylesheet" type="text/css">
    <link href="{{ static('css/idangerous.swiper.css') }}" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="{{ static('js/jquery-1.8.3.min.js') }}"></script>
    <script type="text/javascript" src="{{ static('js/wo.js') }}"></script>
</head>
<body style="background-color: #fff !important;">
<div class="warpe">
    <div class="head">
        <a href="#" class="return"><i class="icon-chevron-left"></i> 返回</a>
        注册
    </div>
    <div class="main">
        <div class="regall">
            <div class="reginput">
                <input type="text" placeholder="身份证号/手机号" id="mobile">
                <input type="text" placeholder="验证码" id="code" style="border-top: .1rem #ededed solid;">
                <div class="yzmdiv">
                    <a href="#" id="bt01">获取验证码</a>
                </div>
            </div>
            <div class="regTxt">
                <p><label><input type="checkbox" checked="false">同意"智彗社区注册与服务协议"</label></p>
            </div>
            <div class="id_bth inersest_bth animated bounceIn">
                <a href="{{ url('users:register2') }}" id="ajax" type="text">下一步</a>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    var bt01 = document.getElementById("bt01");
    bt01.onclick = function () {
        var mobile = $('#mobile').val();
        var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
        if (!myreg.test(mobile)) {
            alert('手机号格式有误');

        }
        var send_url = '/sms_codes/';
        $.ajax({
            type: "GET",
            url: send_url,
            data : {
                    "mobile" : mobile
                },
            success: function (data) {
                if (data.errno == "0") {
                    console.log('success')
                } else {
                    alert(data.errmsg)
                }
            }
        });
        bt01.disabled = true;  //当点击后倒计时时候不能点击此按钮
        var time = 60;  //倒计时5秒
        var timer = setInterval(fun1, 1000);  //设置定时器
        function fun1() {
            time--;
            if (time >= 0) {
                bt01.innerHTML = time + "s后重新发送";
            } else {
                bt01.innerHTML = "重新发送验证码";
                bt01.disabled = false;  //倒计时结束能够重新点击发送的按钮
                clearTimeout(timer);  //清除定时器
                time = 60;  //设置循环重新开始条件
            }
        }
    };








    $('#ajax').click(function () {
        var mobile = document.getElementById("mobile").value;
        var sms_code = document.getElementById("code").value;
        $.ajax({
            type: 'POST',
            url: '/register2/',
            data: {
                'mobile': mobile,
                {#'sms_code': sms_code#}
            },
            {#dataType:"json",#}
            success: function (data) {
                if (data.errno == "0") {
                    console.log('success')
                } else {
                    alert(data.errmsg)
                }
            }
        })
    })



</script>
</body>
</html>